package com.data2wisdom.comm.base.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import com.github.pagehelper.PageInfo;

import io.swagger.annotations.ApiModelProperty;

public class APILogResponse<T>{
	   public static final int SUCCESS = 0;//请求状态
	    public static final int FAIL = -1;
	    @ApiModelProperty(value = "消息编号：0=成功，<0表示异常")
	    private int msgCode = SUCCESS;
	    @ApiModelProperty(value = "消息内容")
	    private String msg = "成功";
	    @ApiModelProperty(value = "API数据")
	    private List<T> data = new ArrayList<T>();//返回集合对象
	    private List<FieldObj> fieldList = new ArrayList<FieldObj>();
	    private List<List<String>> cpData = new ArrayList<>();
	    private T object;//返回单个对象
	    private long total;//总记录数
	    private long iTotalDisplayRecords; 
	    private long iTotalRecords;
	    private int totalPage;//总页数
	    private int currPage;//当前页
	    private Timestamp nowTime;
	    
	    private String pjtId;
	    
	    
	    public APILogResponse( List<List<String>> cpData ) {
	    	this.cpData = cpData;
	    }
	    /**
	     * 构造函数：不分页数据
	     * @param pageData
	     */
	    public APILogResponse( List<T> data,List<FieldObj> fieldList) {
	    	this.data = data;
	    	this.fieldList = fieldList;
	    }
	    
	    /**
	     * 构造函数：分页数据
	     * @param pageData
	     */
	    public APILogResponse(PageDto<T> pageData,List<FieldObj> fieldList) {
	    	if (null!=pageData) {
	    		data=pageData.getData();
	    		total=pageData.getTotal();
	    		totalPage=pageData.getTotalPage();
	    		currPage=pageData.getCurrPage();
			}
	    	this.fieldList = fieldList;
	    }
	    /**
	     * 构造函数：分页数据
	     * @param pageData
	     */
	    public APILogResponse(PageInfo<T> pageInfo,List<FieldObj> fieldList) {
	    	if (null!=pageInfo) {
	    		data=pageInfo.getList();
	    		total=pageInfo.getTotal();
	    		iTotalDisplayRecords=pageInfo.getTotal();
	    		iTotalRecords=pageInfo.getTotal();
	    		totalPage=pageInfo.getPages();
	    		currPage=pageInfo.getPageNum();
			}
	    	this.fieldList = fieldList;
	    }
	    
	    
	    /**
	     * 构造函数：分页数据
	     * @param pageData
	     */
	    public APILogResponse(PageDto<T> pageData) {
	    	if (null!=pageData) {
	    		data=pageData.getData();
	    		total=pageData.getTotal();
	    		totalPage=pageData.getTotalPage();
	    		currPage=pageData.getCurrPage();
			}
	    }
	    /**
	     * 构造函数：分页数据
	     * @param pageData
	     */
	    public APILogResponse(PageInfo<T> pageInfo) {
	    	if (null!=pageInfo) {
	    		data=pageInfo.getList();
	    		total=pageInfo.getTotal();
	    		iTotalDisplayRecords=pageInfo.getTotal();
	    		iTotalRecords=pageInfo.getTotal();
	    		totalPage=pageInfo.getPages();
	    		currPage=pageInfo.getPageNum();
			}
	    }
	    
	    
	    
	    /**
	     * 构造函数：集合数据
	     * @param data
	     */
	   /* public APILogResponse(List<T> data) {
	    	if (null!=data) {
	    		this.data=data;
	    		total=data.size();
			}
	    }*/
	    /**
	     * 构造函数：自定义分页数据
	     * @param data
	     * @param total
	     * @param totalPage
	     * @param currPage
	     */
	    public APILogResponse(List<T> data,Long total,int totalPage,int currPage) {
	    	if (null!=data) {
	    		this.data=data;
	    		this.total=total;
	    		this.totalPage=totalPage;
	    		this.currPage=currPage;
			}
	    }
	    /**
	     * 构造函数：单个模型数据
	     * @param returnData
	     */
	  /*  public APILogResponse(T returnData) {
	    	object=returnData;
	    }*/
	    /**
	     * 构造函数：单个消息
	     * @param msg
	     */
	    public APILogResponse(String msg) {
	        this.msg = msg;
	    }
	    /**
	     * 构造函数：消息和消息码
	     * @param msg
	     */
	    public APILogResponse(int msgCode, String msg) {
	        this.msgCode = msgCode;
	        this.msg = msg;
	    }
	    
	    
		public int getMsgCode() {
			return msgCode;
		}
		public void setMsgCode(int msgCode) {
			this.msgCode = msgCode;
		}
		public String getMsg() {
			return msg;
		}
		public void setMsg(String msg) {
			this.msg = msg;
		}
		public List<T> getData() {
			return data;
		}
		public void setData(List<T> data) {
			this.data = data;
		}
		public List<FieldObj> getFieldList() {
			return fieldList;
		}
		public void setFieldList(List<FieldObj> fieldList) {
			this.fieldList = fieldList;
		}
		public T getObject() {
			return object;
		}
		public void setObject(T object) {
			this.object = object;
		}
		public long getTotal() {
			return total;
		}
		public void setTotal(long total) {
			this.total = total;
		}
		public long getiTotalDisplayRecords() {
			return iTotalDisplayRecords;
		}
		public void setiTotalDisplayRecords(long iTotalDisplayRecords) {
			this.iTotalDisplayRecords = iTotalDisplayRecords;
		}
		public long getiTotalRecords() {
			return iTotalRecords;
		}
		public void setiTotalRecords(long iTotalRecords) {
			this.iTotalRecords = iTotalRecords;
		}
		public int getTotalPage() {
			return totalPage;
		}
		public void setTotalPage(int totalPage) {
			this.totalPage = totalPage;
		}
		public int getCurrPage() {
			return currPage;
		}
		public void setCurrPage(int currPage) {
			this.currPage = currPage;
		}
		public Timestamp getNowTime() {
			return nowTime;
		}
		public void setNowTime(Timestamp nowTime) {
			this.nowTime = nowTime;
		}
		public static int getSuccess() {
			return SUCCESS;
		}
		public static int getFail() {
			return FAIL;
		}
		public String getPjtId() {
			return pjtId;
		}
		public void setPjtId(String pjtId) {
			this.pjtId = pjtId;
		}
		public List<List<String>> getCpData() {
			return cpData;
		}
		public void setCpData(List<List<String>> cpData) {
			this.cpData = cpData;
		}
	    
}
